#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<string.h>


void Spin(char* str, int n) {
	int len = strlen(str);
	char str1[30] = { 0 };
	for (int i = 1; i <= n; i++) {
		str1[i - 1] = str[i - 1];
	}
	for (int j = 1; j <=len- n; j++) {
		str[j - 1] = str[j+n-1];
	}
	for (int k = 1; k <= n; k++) {
		str[len+k-n-1] = str1[k - 1];
	}
}

int main() {
	char str[30] = { 0 };
	int n = 0;
	gets(str);
	scanf("%d", &n);
	Spin(str, n);
	puts(str);
	return 0;
}